Repository navigation
fix(libSceSystemService): run guest exit handlers first on LoadExec exit - #4872
Merged
oneandonlydean merged 1 commit intoOct 13, 2026
Conversation
10 tasks done
10 tasks done
10 tasks done
10 tasks done
Collaborator
|
Needs a rebase: |
David-cmrg
force-pushed
the
fix/systemservice-loadexec-exit-order
branch
from
October 13, 2026 10:05
9a5090a to
9f9c351
Compare
Contributor
Author
|
Rebased onto On Linux (GCC 16.2.1, Release), the six |
11 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #4846.
sceSystemServiceLoadExec("exit")ranLibcRunShutdown_nid_postfix()and thenstd::exit(0). The title's own exit handlers (__cxa_atexit, run byCxaFinalize_nid_no_patchfrom the hostatexitentry registered at the first guest registration) then ran after the host exit handlers registered later, among them the destructors of host statics such as theGuestAllocationsregistry. A guest destructor that frees heap memory then reads the destroyed registry. In ProsperoEden the freed entry reads as pinned, so the free waitsAPS5_PIN_WAIT_MSand the process aborts.It now exits through
LibcExit_nid_no_patch(0), likeexit, a return frommainandsceSystemServiceKillApp: shutdown, then the guest exit handlers, thenstd::exit, and it waits when another thread already started exiting. That is the orderguest_exit_orderrequires ("guest exit handlers must run before the host exit handlers").guest_system_exitnow registers a guest exit handler before its hostatexithandler and requires that the guest one ran first.Tested
Fedora 44, GCC 16.2.1, Release.
main510a2188c: with the test change alone,guest_system_exitfails 3 of 3; with this change it passes 3 of 3.guest_exit_order,guest_system_exit*,guest_quick_exit,guest_immediate_exit,guest_return_from_main,guest_system_kill_app*andguest_system_service*(11 tests) pass.d53960612(the files this PR touches are unchanged since then), withdataalready in the run folder. The title quits from its launcher after about 19 s.data.#4786 changes the same function (a relaunch for the title's own
eboot.bin) and keepsLibcRunShutdown_nid_postfix(); std::exit(0);there, so the two PRs touch the same lines.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)